#ifndef IA32SYSCALLINTERNAL_H
#define IA32SYSCALLINTERNAL_H


/*
 * This file contains the system call numbers.
 */

#define IA32_SYS_restart_syscall      0
#define IA32_SYS_exit		  1
#define IA32_SYS_fork		  2
#define IA32_SYS_read		  3
#define IA32_SYS_write		  4
#define IA32_SYS_open		  5
#define IA32_SYS_close		  6
#define IA32_SYS_waitpid		  7
#define IA32_SYS_creat		  8
#define IA32_SYS_link		  9
#define IA32_SYS_unlink		 10
#define IA32_SYS_execve		 11
#define IA32_SYS_chdir		 12
#define IA32_SYS_time		 13
#define IA32_SYS_mknod		 14
#define IA32_SYS_chmod		 15
#define IA32_SYS_lchown		 16
#define IA32_SYS_break		 17
#define IA32_SYS_oldstat		 18
#define IA32_SYS_lseek		 19
#define IA32_SYS_getpid		 20
#define IA32_SYS_mount		 21
#define IA32_SYS_umount		 22
#define IA32_SYS_setuid		 23
#define IA32_SYS_getuid		 24
#define IA32_SYS_stime		 25
#define IA32_SYS_ptrace		 26
#define IA32_SYS_alarm		 27
#define IA32_SYS_oldfstat		 28
#define IA32_SYS_pause		 29
#define IA32_SYS_utime		 30
#define IA32_SYS_stty		 31
#define IA32_SYS_gtty		 32
#define IA32_SYS_access		 33
#define IA32_SYS_nice		 34
#define IA32_SYS_ftime		 35
#define IA32_SYS_sync		 36
#define IA32_SYS_kill		 37
#define IA32_SYS_rename		 38
#define IA32_SYS_mkdir		 39
#define IA32_SYS_rmdir		 40
#define IA32_SYS_dup		 41
#define IA32_SYS_pipe		 42
#define IA32_SYS_times		 43
#define IA32_SYS_prof		 44
#define IA32_SYS_brk		 45
#define IA32_SYS_setgid		 46
#define IA32_SYS_getgid		 47
#define IA32_SYS_signal		 48
#define IA32_SYS_geteuid		 49
#define IA32_SYS_getegid		 50
#define IA32_SYS_acct		 51
#define IA32_SYS_umount2		 52
#define IA32_SYS_lock		 53
#define IA32_SYS_ioctl		 54
#define IA32_SYS_fcntl		 55
#define IA32_SYS_mpx		 56
#define IA32_SYS_setpgid		 57
#define IA32_SYS_ulimit		 58
#define IA32_SYS_oldolduname	 59
#define IA32_SYS_umask		 60
#define IA32_SYS_chroot		 61
#define IA32_SYS_ustat		 62
#define IA32_SYS_dup2		 63
#define IA32_SYS_getppid		 64
#define IA32_SYS_getpgrp		 65
#define IA32_SYS_setsid		 66
#define IA32_SYS_sigaction		 67
#define IA32_SYS_sgetmask		 68
#define IA32_SYS_ssetmask		 69
#define IA32_SYS_setreuid		 70
#define IA32_SYS_setregid		 71
#define IA32_SYS_sigsuspend		 72
#define IA32_SYS_sigpending		 73
#define IA32_SYS_sethostname	 74
#define IA32_SYS_setrlimit		 75
#define IA32_SYS_getrlimit		 76	/* Back compatible 2Gig limited rlimit */
#define IA32_SYS_getrusage		 77
#define IA32_SYS_gettimeofday	 78
#define IA32_SYS_settimeofday	 79
#define IA32_SYS_getgroups		 80
#define IA32_SYS_setgroups		 81
#define IA32_SYS_select		 82
#define IA32_SYS_symlink		 83
#define IA32_SYS_oldlstat		 84
#define IA32_SYS_readlink		 85
#define IA32_SYS_uselib		 86
#define IA32_SYS_swapon		 87
#define IA32_SYS_reboot		 88
#define IA32_SYS_readdir		 89
#define IA32_SYS_mmap		 90
#define IA32_SYS_munmap		 91
#define IA32_SYS_truncate		 92
#define IA32_SYS_ftruncate		 93
#define IA32_SYS_fchmod		 94
#define IA32_SYS_fchown		 95
#define IA32_SYS_getpriority	 96
#define IA32_SYS_setpriority	 97
#define IA32_SYS_profil		 98
#define IA32_SYS_statfs		 99
#define IA32_SYS_fstatfs		100
#define IA32_SYS_ioperm		101
#define IA32_SYS_socketcall		102
#define IA32_SYS_syslog		103
#define IA32_SYS_setitimer		104
#define IA32_SYS_getitimer		105
#define IA32_SYS_stat		106
#define IA32_SYS_lstat		107
#define IA32_SYS_fstat		108
#define IA32_SYS_olduname		109
#define IA32_SYS_iopl		110
#define IA32_SYS_vhangup		111
#define IA32_SYS_idle		112
#define IA32_SYS_vm86old		113
#define IA32_SYS_wait4		114
#define IA32_SYS_swapoff		115
#define IA32_SYS_sysinfo		116
#define IA32_SYS_ipc		117
#define IA32_SYS_fsync		118
#define IA32_SYS_sigreturn		119
#define IA32_SYS_clone		120
#define IA32_SYS_setdomainname	121
#define IA32_SYS_uname		122
#define IA32_SYS_modify_ldt		123
#define IA32_SYS_adjtimex		124
#define IA32_SYS_mprotect		125
#define IA32_SYS_sigprocmask	126
#define IA32_SYS_create_module	127
#define IA32_SYS_init_module	128
#define IA32_SYS_delete_module	129
#define IA32_SYS_get_kernel_syms	130
#define IA32_SYS_quotactl		131
#define IA32_SYS_getpgid		132
#define IA32_SYS_fchdir		133
#define IA32_SYS_bdflush		134
#define IA32_SYS_sysfs		135
#define IA32_SYS_personality	136
#define IA32_SYS_afs_syscall	137 /* Syscall for Andrew File System */
#define IA32_SYS_setfsuid		138
#define IA32_SYS_setfsgid		139
#define IA32_SYS__llseek		140
#define IA32_SYS_getdents		141
#define IA32_SYS__newselect		142
#define IA32_SYS_flock		143
#define IA32_SYS_msync		144
#define IA32_SYS_readv		145
#define IA32_SYS_writev		146
#define IA32_SYS_getsid		147
#define IA32_SYS_fdatasync		148
#define IA32_SYS__sysctl		149
#define IA32_SYS_mlock		150
#define IA32_SYS_munlock		151
#define IA32_SYS_mlockall		152
#define IA32_SYS_munlockall		153
#define IA32_SYS_sched_setparam		154
#define IA32_SYS_sched_getparam		155
#define IA32_SYS_sched_setscheduler		156
#define IA32_SYS_sched_getscheduler		157
#define IA32_SYS_sched_yield		158
#define IA32_SYS_sched_get_priority_max	159
#define IA32_SYS_sched_get_priority_min	160
#define IA32_SYS_sched_rr_get_interval	161
#define IA32_SYS_nanosleep		162
#define IA32_SYS_mremap		163
#define IA32_SYS_setresuid		164
#define IA32_SYS_getresuid		165
#define IA32_SYS_vm86		166
#define IA32_SYS_query_module	167
#define IA32_SYS_poll		168
#define IA32_SYS_nfsservctl		169
#define IA32_SYS_setresgid		170
#define IA32_SYS_getresgid		171
#define IA32_SYS_prctl              172
#define IA32_SYS_rt_sigreturn	173
#define IA32_SYS_rt_sigaction	174
#define IA32_SYS_rt_sigprocmask	175
#define IA32_SYS_rt_sigpending	176
#define IA32_SYS_rt_sigtimedwait	177
#define IA32_SYS_rt_sigqueueinfo	178
#define IA32_SYS_rt_sigsuspend	179
#define IA32_SYS_pread64		180
#define IA32_SYS_pwrite64		181
#define IA32_SYS_chown		182
#define IA32_SYS_getcwd		183
#define IA32_SYS_capget		184
#define IA32_SYS_capset		185
#define IA32_SYS_sigaltstack	186
#define IA32_SYS_sendfile		187
#define IA32_SYS_getpmsg		188	/* some people actually want streams */
#define IA32_SYS_putpmsg		189	/* some people actually want streams */
#define IA32_SYS_vfork		190
#define IA32_SYS_ugetrlimit		191	/* SuS compliant getrlimit */
#define IA32_SYS_mmap2		192
#define IA32_SYS_truncate64		193
#define IA32_SYS_ftruncate64	194
#define IA32_SYS_stat64		195
#define IA32_SYS_lstat64		196
#define IA32_SYS_fstat64		197
#define IA32_SYS_lchown32		198
#define IA32_SYS_getuid32		199
#define IA32_SYS_getgid32		200
#define IA32_SYS_geteuid32		201
#define IA32_SYS_getegid32		202
#define IA32_SYS_setreuid32		203
#define IA32_SYS_setregid32		204
#define IA32_SYS_getgroups32	205
#define IA32_SYS_setgroups32	206
#define IA32_SYS_fchown32		207
#define IA32_SYS_setresuid32	208
#define IA32_SYS_getresuid32	209
#define IA32_SYS_setresgid32	210
#define IA32_SYS_getresgid32	211
#define IA32_SYS_chown32		212
#define IA32_SYS_setuid32		213
#define IA32_SYS_setgid32		214
#define IA32_SYS_setfsuid32		215
#define IA32_SYS_setfsgid32		216
#define IA32_SYS_pivot_root		217
#define IA32_SYS_mincore		218
#define IA32_SYS_madvise		219
#define IA32_SYS_madvise1		219	/* delete when C lib stub is removed */
#define IA32_SYS_getdents64		220
#define IA32_SYS_fcntl64		221
/* 223 is unused */
#define IA32_SYS_gettid		224
#define IA32_SYS_readahead		225
#define IA32_SYS_setxattr		226
#define IA32_SYS_lsetxattr		227
#define IA32_SYS_fsetxattr		228
#define IA32_SYS_getxattr		229
#define IA32_SYS_lgetxattr		230
#define IA32_SYS_fgetxattr		231
#define IA32_SYS_listxattr		232
#define IA32_SYS_llistxattr		233
#define IA32_SYS_flistxattr		234
#define IA32_SYS_removexattr	235
#define IA32_SYS_lremovexattr	236
#define IA32_SYS_fremovexattr	237
#define IA32_SYS_tkill		238
#define IA32_SYS_sendfile64		239
#define IA32_SYS_futex		240
#define IA32_SYS_sched_setaffinity	241
#define IA32_SYS_sched_getaffinity	242
#define IA32_SYS_set_thread_area	243
#define IA32_SYS_get_thread_area	244
#define IA32_SYS_io_setup		245
#define IA32_SYS_io_destroy		246
#define IA32_SYS_io_getevents	247
#define IA32_SYS_io_submit		248
#define IA32_SYS_io_cancel		249
#define IA32_SYS_fadvise64		250
/* 251 is available for reuse (was briefly sys_set_zone_reclaim) */
#define IA32_SYS_exit_group		252
#define IA32_SYS_lookup_dcookie	253
#define IA32_SYS_epoll_create	254
#define IA32_SYS_epoll_ctl		255
#define IA32_SYS_epoll_wait		256
#define IA32_SYS_remap_file_pages	257
#define IA32_SYS_set_tid_address	258
#define IA32_SYS_timer_create	259
#define IA32_SYS_timer_settime	(IA32_SYS_timer_create+1)
#define IA32_SYS_timer_gettime	(IA32_SYS_timer_create+2)
#define IA32_SYS_timer_getoverrun	(IA32_SYS_timer_create+3)
#define IA32_SYS_timer_delete	(IA32_SYS_timer_create+4)
#define IA32_SYS_clock_settime	(IA32_SYS_timer_create+5)
#define IA32_SYS_clock_gettime	(IA32_SYS_timer_create+6)
#define IA32_SYS_clock_getres	(IA32_SYS_timer_create+7)
#define IA32_SYS_clock_nanosleep	(IA32_SYS_timer_create+8)
#define IA32_SYS_statfs64		268
#define IA32_SYS_fstatfs64		269
#define IA32_SYS_tgkill		270
#define IA32_SYS_utimes		271
#define IA32_SYS_fadvise64_64	272
#define IA32_SYS_vserver		273
#define IA32_SYS_mbind		274
#define IA32_SYS_get_mempolicy	275
#define IA32_SYS_set_mempolicy	276
#define IA32_SYS_mq_open 		277
#define IA32_SYS_mq_unlink		(IA32_SYS_mq_open+1)
#define IA32_SYS_mq_timedsend	(IA32_SYS_mq_open+2)
#define IA32_SYS_mq_timedreceive	(IA32_SYS_mq_open+3)
#define IA32_SYS_mq_notify		(IA32_SYS_mq_open+4)
#define IA32_SYS_mq_getsetattr	(IA32_SYS_mq_open+5)
#define IA32_SYS_kexec_load		283
#define IA32_SYS_waitid		284
/* #define IA32_SYS_sys_setaltroot	285 */
#define IA32_SYS_add_key		286
#define IA32_SYS_request_key	287
#define IA32_SYS_keyctl		288
#define IA32_SYS_ioprio_set		289
#define IA32_SYS_ioprio_get		290
#define IA32_SYS_inotify_init	291
#define IA32_SYS_inotify_add_watch	292
#define IA32_SYS_inotify_rm_watch	293
#define IA32_SYS_migrate_pages	294
#define IA32_SYS_openat		295
#define IA32_SYS_mkdirat		296
#define IA32_SYS_mknodat		297
#define IA32_SYS_fchownat		298
#define IA32_SYS_futimesat		299
#define IA32_SYS_fstatat64		300
#define IA32_SYS_unlinkat		301
#define IA32_SYS_renameat		302
#define IA32_SYS_linkat		303
#define IA32_SYS_symlinkat		304
#define IA32_SYS_readlinkat		305
#define IA32_SYS_fchmodat		306
#define IA32_SYS_faccessat		307
#define IA32_SYS_pselect6		308
#define IA32_SYS_ppoll		309
#define IA32_SYS_unshare		310
#define IA32_SYS_set_robust_list	311
#define IA32_SYS_get_robust_list	312
#define IA32_SYS_splice		313
#define IA32_SYS_sync_file_range	314
#define IA32_SYS_tee		315
#define IA32_SYS_vmsplice		316
#define IA32_SYS_move_pages		317
#define IA32_SYS_getcpu		318
#define IA32_SYS_epoll_pwait	319

/* total bytes to copy from a valid pointer argument for ioctl() calls,
   syscall.c does not decode ioctl() calls to determine the size of the
   arguments that reside in memory, instead, the ioctl() proxy simply copies
   NUM_IOCTL_BYTES bytes from the pointer argument to host memory */
#define NUM_IOCTL_BYTES		128

/* IA32trix ioctl values */
#define IA32_IOCTL_TIOCGETP	1074164744
#define IA32_IOCTL_TIOCSETP	-2147060727
#define IA32_IOCTL_TCGETP		1076130901
#define IA32_IOCTL_TCGETA		1075082331
#define IA32_IOCTL_TIOCGLTC	1074164852
#define IA32_IOCTL_TIOCSLTC	-2147060619
#define IA32_IOCTL_TIOCGWINSZ	1074295912
#define IA32_IOCTL_TCSETAW	-2146143143
#define IA32_IOCTL_TIOCGETC	1074164754
#define IA32_IOCTL_TIOCSETC	-2147060719
#define IA32_IOCTL_TIOCLBIC	-2147191682
#define IA32_IOCTL_TIOCLBIS	-2147191681
#define IA32_IOCTL_TIOCLGET	0x4004747c
#define IA32_IOCTL_TIOCLSET	-2147191683

/* open(2) flags for SimpleScalar target, syscall.c automagically maps
   between these codes to/from host open(2) flags */
#define IA32_O_RDONLY		0
#define IA32_O_WRONLY		1
#define IA32_O_RDWR		2
#define IA32_O_APPEND		0x0008
#define IA32_O_CREAT		0x0200
#define IA32_O_TRUNC		0x0400
#define IA32_O_EXCL		0x0800
#define IA32_O_NONBLOCK		0x4000
#define IA32_O_NOCTTY		0x8000
#define IA32_O_SYNC		0x2000

typedef int bool_t;			/* generic boolean type */
typedef unsigned char byte_t;		/* byte - 8 bits */
typedef signed char sbyte_t;
typedef unsigned short half_t;		/* half - 16 bits */
typedef signed short shalf_t;
typedef unsigned int word_t;		/* word - 32 bits */
typedef signed int sword_t;
typedef float sfloat_t;			/* single-precision float - 32 bits */
typedef double dfloat_t;		/* double-precision float - 64 bits */

#if 0
/* target stat() buffer definition, the host stat buffer format is
   automagically mapped to/from this format in syscall.c */
struct ss_statbuf
{
  shalf_t ss_st_dev;
  shalf_t ss_pad;
  word_t ss_st_ino;
  half_t ss_st_mode;
  shalf_t ss_st_nlink;
  shalf_t ss_st_uid;
  shalf_t ss_st_gid;
  shalf_t ss_st_rdev;
  shalf_t ss_pad1;
  sword_t ss_st_size;
  sword_t ss_st_atime;
  sword_t ss_st_spare1;
  sword_t ss_st_mtime;
  sword_t ss_st_spare2;
  sword_t ss_st_ctime;
  sword_t ss_st_spare3;
  sword_t ss_st_blksize;
  sword_t ss_st_blocks;
  word_t ss_st_gennum;
  sword_t ss_st_spare4;
};

struct ss_sgttyb {
  byte_t sg_ispeed;     /* input speed */
  byte_t sg_ospeed;     /* output speed */
  byte_t sg_erase;      /* erase character */
  byte_t sg_kill;       /* kill character */
  shalf_t sg_flags;     /* mode flags */
};

struct ss_timeval
{
  sword_t ss_tv_sec;		/* seconds */
  sword_t ss_tv_usec;		/* microseconds */
};

/* target getrusage() buffer definition, the host stat buffer format is
   automagically mapped to/from this format in syscall.c */
struct ss_rusage
{
  struct ss_timeval ss_ru_utime;
  struct ss_timeval ss_ru_stime;
  sword_t ss_ru_maxrss;
  sword_t ss_ru_ixrss;
  sword_t ss_ru_idrss;
  sword_t ss_ru_isrss;
  sword_t ss_ru_minflt;
  sword_t ss_ru_majflt;
  sword_t ss_ru_nswap;
  sword_t ss_ru_inblock;
  sword_t ss_ru_oublock;
  sword_t ss_ru_msgsnd;
  sword_t ss_ru_msgrcv;
  sword_t ss_ru_nsignals;
  sword_t ss_ru_nvcsw;
  sword_t ss_ru_nivcsw;
};

struct ss_timezone
{
  sword_t ss_tz_minuteswest;	/* minutes west of Greenwich */
  sword_t ss_tz_dsttime;	/* type of dst correction */
};

struct ss_rlimit
{
  int ss_rlim_cur;		/* current (soft) limit */
  int ss_rlim_max;		/* maximum value for rlim_cur */
};

/* open(2) flags translation table for SimpleScalar target */
struct open_flag_map {
  int ss_flag;
  int local_flag;
};

#define IA32_NFLAGS	(sizeof(ss_flag_table)/sizeof(ss_flag_table[0]))
#endif

#endif
